package cn.life.business.factory.dao.impl;

import cn.life.business.factory.dao.FactoryDao;
import cn.life.business.factory.entity.po.FactoryPo;
import cn.life.common.entity.model.CMessage;
import cn.life.common.support.jdbc.AbstractSupportDao;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @Description:
 *
 * @Author 李佳明
 * @Date 2018/7/24 0024 下午 1:32
 */
@Repository
public class FactoryDaoImpl extends AbstractSupportDao implements FactoryDao{
    @Override
    public int addFactory(FactoryPo actoryPo) {
        String sql = "insert into factory_info(factory_name,factory_addr,factory_desc,opr_user_id,opr_user_name,opr_date) values(?,?,?,?,?,?)";
        return update(sql,actoryPo.getFactoryName(),actoryPo.getFactoryAddr(),actoryPo.getFactoryDesc(),actoryPo.getOprUserId(),actoryPo.getOprUserName(),getNowDate());
    }

    @Override
    public int updateFactory(FactoryPo actoryPo) {
        String sql = "update factory_info set factory_name = ?,factory_addr = ?,factory_desc = ? where factory_id = ?";
        return update(sql,actoryPo.getFactoryName(),actoryPo.getFactoryAddr(),actoryPo.getFactoryDesc(),actoryPo.getFactoryId());
    }

    @Override
    public int deleteFactory(FactoryPo actoryPo) {
        String sql = "delete from factory_info where factory_id = ?";
        return update(sql,actoryPo.getFactoryId());
    }

    @Override
    public FactoryPo queryFactoryDetail(FactoryPo actoryPo) {
        String sql = "select * from factory_info where factory_id = ?";
        return queryForObject(sql,FactoryPo.class,actoryPo.getFactoryId());
    }


}
